import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JList;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class PasaJList extends JFrame {

	private JPanel contentPane;
	private String[] datos = {"uno","dos","tres","cuatro"};
	private DefaultListModel<String> tDisp;
	private DefaultListModel<String> tAsig;
	private JList lstDisp;
	
	


	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				
				try {
					PasaJList frame = new PasaJList();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public PasaJList() {
		tDisp = new DefaultListModel();
		tAsig= new DefaultListModel();
		for (int i=0;i<datos.length;i++){
			tDisp.addElement(datos[i]);
		}
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		lstDisp = new JList(tDisp);
		lstDisp.setBounds(52, 78, 103, 93);
		contentPane.add(lstDisp);
		
		JButton btn1 = new JButton(">");
		btn1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				tAsig.addElement(tDisp.remove(lstDisp.getSelectedIndex()));
			
			}
		});
		btn1.setBounds(169, 75, 89, 23);
		contentPane.add(btn1);
		
		JList lstAsig = new JList(tAsig);
		lstAsig.setBounds(268, 78, 103, 93);
		contentPane.add(lstAsig);
		
		JButton btn2 = new JButton(">");
		btn2.setBounds(169, 98, 89, 23);
		contentPane.add(btn2);
		btn2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				for (int i=0;i<tDisp.getSize();i++)
					tAsig.addElement(tDisp.getElementAt(i));
				tDisp.removeAllElements();
			
			}
		});
		JButton btn3 = new JButton(">");
		btn3.setBounds(165, 125, 89, 23);
		contentPane.add(btn3);
		
		JButton btn4 = new JButton(">");
		btn4.setBounds(165, 148, 89, 23);
		contentPane.add(btn4);
	}
}
